
import time
import traceback
from huobi.exception.huobi_api_exception import HuobiApiException
from huobi.utils.log_info import Log
from quant_mgr import QuantMgr



def main():
    Log.init_log()
    Log.info("main start")
    quant_mgr = QuantMgr.getinstance()
    while True:
        begin_time = time.time()
        delta = 0.1

        try:
            quant_mgr.update()
            pass
        except HuobiApiException as e:
            if e.error_code != HuobiApiException.NO_RESPONSE:
                Log.error(e.error_message)
        except Exception as e:
            Log.error(str(traceback.format_exc()))

        end_time = time.time()
        diff = end_time-begin_time
        if diff < delta:
            time.sleep(delta-diff)








if __name__ == '__main__':
    main()